<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>par_trajectory_planning: /home/wouter/ros_packages/thp-pj2-08/par_trajectory_planning/src/par_planning.cpp Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>

<table border="0">
<tr><td valign="top" style="border-right: 1px solid #333; padding-right: 10px;" >
<p>
Project: <a href="http://ros.org/wiki/par_trajectory_planning">par_trajectory_planning</a>
</p>
<p>
License: BSD
</p>
<p>
Dependencies: 
<ul>
  <li>std_msgs</li>
  <li>roscpp</li>
</ul>
</p>
<p>
Used by:
None<br />
</p>
<p>
<a href="../../index.html">All Packages</a>
</p>

</div>
</td><td valign="top" style="padding-left: 10px;" >
<!-- Generated by Doxygen 1.7.1 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<h1>/home/wouter/ros_packages/thp-pj2-08/par_trajectory_planning/src/par_planning.cpp</h1>  </div>
</div>
<div class="contents">
<a href="par__planning_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00005"></a>00005 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00006"></a>00006 <span class="preprocessor">#include &lt;ros/ros.h&gt;</span>
<a name="l00007"></a>00007 <span class="preprocessor">#include &lt;<a class="code" href="commands_8h.html">par_trajectory_planning/commands.h</a>&gt;</span>
<a name="l00008"></a>00008 <span class="preprocessor">#include &lt;<a class="code" href="steppermotor_8h.html">par_trajectory_planning/steppermotor.h</a>&gt;</span>
<a name="l00009"></a>00009 <span class="preprocessor">#include &lt;<a class="code" href="config_8h.html">par_trajectory_planning/config.h</a>&gt;</span>
<a name="l00010"></a>00010 <span class="preprocessor">#include &lt;cerrno&gt;</span>
<a name="l00011"></a>00011 
<a name="l00012"></a><a class="code" href="par__planning_8cpp.html#a9e4984bb4763bc6694e8a9b6a624f79d">00012</a> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="par__planning_8cpp.html#a9e4984bb4763bc6694e8a9b6a624f79d">QUEUE_SIZE</a> = 1000;
<a name="l00013"></a><a class="code" href="par__planning_8cpp.html#a38b38217175fdd503e34b3e7c682f577">00013</a> <span class="keyword">static</span> <a class="code" href="classStepperMotor.html">StepperMotor</a>* <a class="code" href="par__planning_8cpp.html#a38b38217175fdd503e34b3e7c682f577">stepperMotor</a>;
<a name="l00014"></a>00014 
<a name="l00019"></a><a class="code" href="par__planning_8cpp.html#a55268b4735960b989898bc4f4c3c1ead">00019</a> <span class="keywordtype">void</span> <a class="code" href="par__planning_8cpp.html#a55268b4735960b989898bc4f4c3c1ead" title="This is the callback function responsible for receiving and processing commands from the user...">commands</a>(<span class="keyword">const</span> <a class="code" href="structpar__trajectory__planning_1_1commands__.html">par_trajectory_planning::commands</a>&amp; cmd)
<a name="l00020"></a>00020 {
<a name="l00021"></a>00021     <span class="keywordflow">switch</span>(cmd.<a class="code" href="structpar__trajectory__planning_1_1commands__.html#aa3e04853d4f1d50c41eca9477611eb7e">option</a>)
<a name="l00022"></a>00022     {
<a name="l00023"></a>00023         <span class="keywordflow">case</span> <a class="code" href="config_8h.html#aa1cc4a54df959fcc4152e206023c0aae">MENU_INIT_COMM</a>:
<a name="l00024"></a>00024             stepperMotor-&gt;<a class="code" href="classStepperMotor.html#ab0bd4fe04741af8b74eaecbce0f1b132" title="Function for initializing communication.">initCom</a>();
<a name="l00025"></a>00025         <span class="keywordflow">break</span>;
<a name="l00026"></a>00026         <span class="keywordflow">case</span> <a class="code" href="config_8h.html#a195b55192f1d4a5c03500638d2c6044e">MENU_INIT_MOTOR</a>: 
<a name="l00027"></a>00027             stepperMotor-&gt;<a class="code" href="classStepperMotor.html#aeb9715654c67df9981f2690bf332f897" title="Function for initializing the motor.">init</a>();
<a name="l00028"></a>00028         <span class="keywordflow">break</span>;
<a name="l00029"></a>00029         <span class="keywordflow">case</span> <a class="code" href="config_8h.html#adc3d5d02c1db33ab0f61c24fe07fc975">MENU_CONF_SIN_MOT</a>:
<a name="l00030"></a>00030             stepperMotor-&gt;<a class="code" href="classStepperMotor.html#a84203d36566a8ce31c35a2655d5dca99" title="Function for configuring single motions.">confSingleMotion</a>(cmd);
<a name="l00031"></a>00031         <span class="keywordflow">break</span>;
<a name="l00032"></a>00032         <span class="keywordflow">case</span> <a class="code" href="config_8h.html#ae844d735df671eb4356a12b1869e2544">MENU_CONF_PTP_MOT</a>:
<a name="l00033"></a>00033             stepperMotor-&gt;<a class="code" href="classStepperMotor.html#acfcb85ea01c6274998ae2e2b0a6c17c3" title="Function for configuring PTP motions.">confPTPMotion</a>(cmd);
<a name="l00034"></a>00034         <span class="keywordflow">break</span>;
<a name="l00035"></a>00035         <span class="keywordflow">case</span> <a class="code" href="config_8h.html#a1de71d5b137d4766a729c476ef68f3cf">MENU_START_MOT</a>:
<a name="l00036"></a>00036             stepperMotor-&gt;<a class="code" href="classStepperMotor.html#a4b25a3c298a270d4952f13e25bfb8acc" title="Function for starting the motor.">start</a>();
<a name="l00037"></a>00037         <span class="keywordflow">break</span>;
<a name="l00038"></a>00038             <span class="keywordflow">case</span> <a class="code" href="config_8h.html#a3847d2f21d6500c9366ac3ffc58dd169">MENU_START_HM</a>:
<a name="l00039"></a>00039             stepperMotor-&gt;<a class="code" href="classStepperMotor.html#a84203d36566a8ce31c35a2655d5dca99" title="Function for configuring single motions.">confSingleMotion</a>(cmd);
<a name="l00040"></a>00040                 stepperMotor-&gt;<a class="code" href="classStepperMotor.html#a4b25a3c298a270d4952f13e25bfb8acc" title="Function for starting the motor.">start</a>();
<a name="l00041"></a>00041             <span class="keywordflow">break</span>;
<a name="l00042"></a>00042             <span class="keywordflow">case</span> <a class="code" href="config_8h.html#ad7942e9282bfcc8dd77636877f60efb9">MENU_STOP_MOT</a>:
<a name="l00043"></a>00043                 stepperMotor-&gt;<a class="code" href="classStepperMotor.html#af0d3c2e75ec64175fefaeeb0914432ff" title="Function for stopping the motor.">stop</a>();
<a name="l00044"></a>00044             <span class="keywordflow">break</span>;
<a name="l00045"></a>00045             <span class="keywordflow">case</span> <a class="code" href="config_8h.html#af9e2ad4aa40ff8319eb5e8f8982cbf95">MENU_START_TEST</a>:
<a name="l00046"></a>00046                 stepperMotor-&gt;<a class="code" href="classStepperMotor.html#a9f9b3d4bf835d5b157c2b9a8f015c87c" title="Function for developing purposes.">test</a>();
<a name="l00047"></a>00047             <span class="keywordflow">break</span>;
<a name="l00048"></a>00048         <span class="keywordflow">case</span> <a class="code" href="config_8h.html#a26dd0accd561b4bfe425571ecd1b1429">MENU_EXIT</a>:
<a name="l00049"></a>00049             stepperMotor-&gt;<a class="code" href="classStepperMotor.html#ab34933b2081d2f367700bfc13157a1b2" title="Function for exiting.">exit</a>();
<a name="l00050"></a>00050         <span class="keywordflow">break</span>;  
<a name="l00051"></a>00051     }
<a name="l00052"></a>00052 }
<a name="l00053"></a>00053 
<a name="l00054"></a><a class="code" href="par__planning_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627">00054</a> <span class="keywordtype">int</span> <a class="code" href="par__planning_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627">main</a>(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)
<a name="l00055"></a>00055 {
<a name="l00056"></a>00056     std::cout &lt;&lt; <span class="stringliteral">&quot;par_trajectory_planning.&quot;</span> &lt;&lt; std::endl;
<a name="l00057"></a>00057     ros::init(argc, argv, <span class="stringliteral">&quot;par_trajectory_planning&quot;</span>, ros::init_options::NoSigintHandler | ros::init_options::NoRosout);
<a name="l00058"></a>00058     ros::NodeHandle n;
<a name="l00065"></a>00065     modbus_t* ctx = modbus_new_rtu(<span class="stringliteral">&quot;/dev/ttyS0&quot;</span>, 115200, <span class="charliteral">&#39;N&#39;</span>, 8, 1); 
<a name="l00066"></a>00066     stepperMotor = <span class="keyword">new</span> <a class="code" href="classStepperMotor.html">StepperMotor</a>(ctx);
<a name="l00067"></a>00067         ros::Subscriber sub = n.subscribe(<span class="stringliteral">&quot;commands&quot;</span>, <a class="code" href="par__planning_8cpp.html#a9e4984bb4763bc6694e8a9b6a624f79d">QUEUE_SIZE</a>, <a class="code" href="par__planning_8cpp.html#a55268b4735960b989898bc4f4c3c1ead" title="This is the callback function responsible for receiving and processing commands from the user...">commands</a>);
<a name="l00068"></a>00068     ros::spin();
<a name="l00069"></a>00069     
<a name="l00070"></a>00070     <span class="keywordflow">return</span> 0;
<a name="l00071"></a>00071 }
</pre></div></div>
</div>
</td></tr></table>

<hr size="1"><div style="align: right;">
<a href="http://ros.org/wiki/par_trajectory_planning">par_trajectory_planning</a><br />
Author(s): Wouter van Teijlingen</br />
<small>autogenerated on Wed Jun 8 2011 17:11:45</small>
</div>
</body>
</html>
